package com.example.baselib.utils.log;


import com.example.baselib.utils.TextUtils;

/**
 * 配置类
 */
class LogConfig extends ILog.IConfig {


    private LogConfig(ConfigBuilder builder) {
        if (builder.logLevel != null) {
            super.level = builder.logLevel.getLevel();
        }
        if (builder.isPrivate != null) {
            super.isPrivate = builder.isPrivate;
        }
        if (builder.showLineNum != null) {
            super.showLineNum = builder.showLineNum;
        }
        if (!TextUtils.isEmpty(builder.mTag)) {
            super.tag = builder.mTag;
        }
        if (builder.mDomain >= 0 && builder.mDomain <= 1048575) {
            super.domain = builder.mDomain;
        }
    }


    public static class ConfigBuilder {
        private String mTag;
        private Boolean isPrivate;
        private int mDomain = -1;
        private Boolean showLineNum;
        private LogLevel logLevel = LogLevel.DEBUG;

        public ConfigBuilder setTag(String tag) {
            if (!TextUtils.isEmpty(tag)) {
                this.mTag = tag;
            }
            return this;
        }

        public ConfigBuilder setDomain(int mDomain) {
            if (mDomain >= 0 && mDomain <= 1048575) {
                this.mDomain = mDomain;
            }
            return this;
        }

        public ConfigBuilder setPrivate(Boolean isPrivate) {
            this.isPrivate = isPrivate;
            return this;
        }

        public ConfigBuilder setShowLineNum(Boolean isShow) {
            this.showLineNum = isShow;
            return this;
        }

        public ConfigBuilder setLogLevel(LogLevel level) {
            if (level != null) {
                this.logLevel = level;
            }
            return this;
        }


        public LogConfig build() {
            return new LogConfig(this);
        }

    }


}
